﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GtsServer.Service.Model;
using GtsServer.DAL;
using System.Data;

namespace GtsServer.Service.Controller
{
    public class NewDeliveryController : BaseController
    {
        InitInfo info = new InitInfo();
        int goldNum = 0;
        string userAccount = string.Empty;

        public NewDeliveryController() { }

        public NewDeliveryController(InitInfo model, out int goldNum, out string userAccount)
            : base(model, out goldNum, out userAccount)
        {
            this.goldNum = goldNum;
            this.userAccount = userAccount;
            info = model;
        }

        public NewDeliveryResponse GetNewDelivery(NewDeloveryRequest request, string userAccount)
        {
            NewDeliveryResponse response = new NewDeliveryResponse();
            response.control = new ControlManage();
            response.notification = new NotificationManage();

            NewDeliveryInfoDAL infodal = new NewDeliveryInfoDAL();
            response.control.tasktype = 0;
            response.notification.title = "";
            response.notification.msg = "";
            if (!string.IsNullOrEmpty(userAccount))
            {
                DataSet ds = infodal.GetNewDeliveryInfo(userAccount);
                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    response.control.tasktype = Convert.ToInt32(ds.Tables[0].Rows[0]["tasktype"].ToString());
                    response.notification.title = ds.Tables[0].Rows[0]["title"].ToString();
                    response.notification.msg = ds.Tables[0].Rows[0]["msg"].ToString();
                }
            }

            return response;
        }
    }
}
